import service from "@/utils/request";

// 获取问题列表list
export function getQuestionList(offset: number, limit: number) {
  const data = {
    offset,
    limit
  };
  return service({
    url: "/question/list",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

// 查询问题列表list
export function queryQuestionList(content: string, offset: number, limit: number) {
  const data = {
    offset,
    limit,
    content
  };
  return service({
    url: "/question/getAllByContent",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

// 获取问题列表list
export function getQuestionHeatList(offset: number, limit: number) {
  const data = {
    offset,
    limit
  };
  return service({
    url: "/question/listByHeat",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}


// 获取单个问题
export function getQuestionItem(id: number) {
  const data = {
    questionId: id
  };
  return service({
    url: "/question/get",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

export function addQuestion(title: string, imageId: string, content: string, tags: string) {
  const data = {
    title,
    imageId,
    content,
    tags: tags
  };
  return service({
    url: "/question/add",
    headers: {
      isToken: true
    },
    method: "post",
    data
  });
}

export function answerQuestionApi(questionId: string, content: string) {
  const data = {
    questionId,
    content
  };
  return service({
    url: "/question/answer",
    headers: {
      isToken: true
    },
    method: "post",
    data
  });
}

export function queryAnswerListApi(questionId: any, offset: number, limit: number) {
  const data = {
    questionId,
    offset,
    limit
  };
  return service({
    url: "/question/answerList",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

export function queryAllAnswerByUser(offset: number, limit: number) {
  const data = {
    offset,
    limit
  };
  return service({
    url: "/question/getAllAnswerByUser",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

export function queryAllQuestionByUser(offset: number, limit: number) {
  const data = {
    offset,
    limit
  };
  return service({
    url: "/question/getAllByUser",
    headers: {
      isToken: true
    },
    method: "get",
    params: data
  });
}

export function questionReputationChange(questionId: number, reputation: number) {
  const data = {
    questionId,
    reputation
  };
  return service({
    url: "/question/like",
    headers: {
      isToken: true
    },
    method: "post",
    data
  });
}
